// components/birthdaySelector/birthdaySelector.js
const noteBirdthday = '请选择出生日期'
var util = require('../../utils/util.js')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    avatarUrl: {
      type: String,
      value: '../../resources/index_' + util.random(1,6) + '.png',
      observer: function (newVal, oldVal, changedPath) {
        _this = this
        if (newVal.trim() != oldVal.trim()) {
        }
      }
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    birdthDay: noteBirdthday,
    dateSelected: 'unselected',
    isDatePikcerShow: false,
    date: util.formatTime(new Date),
  },
  ready: function () {
  },
  /**
   * 组件的方法列表
   */
  methods: {

    showDatePicker: function () {
      this.setData({
        isDatePikcerShow: true
      })
    },
    bindDateChange(e) {
      this.setData({
        birdthDay: e.detail.value,
        dateSelected: "selected"
      })
      this.triggerEvent('birthdayFinishedHandle', { 'birthday': e.detail.value,'action':1}, {})
    },
    bindDateCancel: function (e){
      this.setData({
        birdthDay: noteBirdthday,
        dateSelected: "unselected"
      })
    },
    goPrePage: function (e) {
      this.triggerEvent('goPre', {}, {})
    },
    nextBtnClick: function (e) {
      if (this.data.dateSelected == 'unselected') {
        wx.showToast({
          title: '亲，生日也是很重要哟',
          icon: 'none'
        })
        return
      }
      this.triggerEvent('goNext', {}, {})
    }
  }
})
